<template>
  <el-dialog :visible.sync="visible" title="查看详情" :close-on-click-modal="false" :close-on-press-escape="false">
    <el-form :model="dataForm" ref="dataForm" :label-width="$i18n.locale === 'en-US' ? '120px' : '120px'">
          <el-form-item label="提现订单号">
          <el-input v-model="dataForm.drawNo" placeholder="提现订单号"></el-input>
      </el-form-item>
          <el-form-item label="用户名">
          <el-input disabled v-model="dataForm.username" placeholder="用户id"></el-input>
      </el-form-item>
      <el-form-item label="开户银行">
          <el-input disabled v-model="dataForm.bankName"></el-input>
      </el-form-item>
	  <el-form-item label="银行卡号">
	      <el-input disabled v-model="dataForm.accNo"></el-input>
	  </el-form-item>
	  <el-form-item label="申请提现金额" prop="cash">
          <el-input disabled v-model="dataForm.cash"></el-input>
      </el-form-item>
	  <el-form-item label="拒绝理由" prop="checkRemark">
	      <el-input  v-model="dataForm.checkRemark"></el-input>
	  </el-form-item>
          
      </el-form>
    <template slot="footer">
      <el-button v-if="dataForm.cashStatus != 2" type="success" @click="visible = false">关闭</el-button>
	  <div v-else>
		  <el-button type="success" @click="dataFormSubmitHandle(3)">审核通过</el-button>
		  <el-button type="danger" @click="dataFormSubmitHandle(-1)">审核拒绝</el-button>
	  </div>
    </template>
  </el-dialog>
</template>

<script>
import debounce from 'lodash/debounce'
export default {
  data () {
    return {
      visible: false,
      dataForm: {
        id: '',
        drawNo: '',
        username: '',
        bankName: '',
        accNo: '',
        cash: '',
        realCash: '',
        taxratio: '',
        cashStatus: '',
        createTime: '',
        getTime: '',
        checkRemark: '',
        checkStaffid: '',
        checkTime: ''
      }
    }
  },
  methods: {
    init () {
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        if (this.dataForm.id) {
          this.getInfo()
        }
      })
    },
    // 获取信息
    getInfo () {
      this.$http.get(`/demo/xlsusersdraws/${this.dataForm.id}`).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        this.dataForm = {
          ...this.dataForm,
          ...res.data
        }
      }).catch(() => {})
    },
    // 表单提交
    dataFormSubmitHandle: debounce(function (cashStatus) {
		this.dataForm.cashStatus = cashStatus;
		let url = cashStatus == 3 ? '/demo/xlsusersdraws/auditPass' : '/demo/xlsusersdraws/auditRefused'
        this.$http['put'](url, this.dataForm).then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          }
          this.$message({
            message: this.$t('prompt.success'),
            type: 'success',
            duration: 500,
            onClose: () => {
              this.visible = false
              this.$emit('refreshDataList')
            }
          })
        }).catch(() => {})
    }, 1000, { 'leading': true, 'trailing': false })
  }
}
</script>
